import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from "path";

// https://vite.dev/config/
export default defineConfig({
  server: {
    proxy: {
      '/api': {
        target: 'http://127.0.0.1:5173',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      }
    }
  },
  resolve: {
    alias: {
      // 需要装@types/node这个包哦，不然__dirname会报错
      '@': path.resolve(__dirname, './src')
    }
  },
  plugins: [react()],
  css: {
    preprocessorOptions: {
      scss: {
        //scss预处理器，会给每个scss文件都自动带上这个import
        additionalData: `@use "@/utils/mixin.scss" as *;`
      }
    }
  }
})
